package com.kavenka.zhufengfm.app.client;

import com.kavenka.zhufengfm.app.modle.DiscoverCategory;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by kavenka on 2015/9/27 0027.
 */
public class DataParse {
    public DataParse() {
    }

    public static List<DiscoverCategory> parserDisciverCater(JSONObject jsonObject){
        List<DiscoverCategory> ret=null;
        if (jsonObject != null) {
            try {
                JSONArray array = jsonObject.getJSONArray("list");
                ret=new LinkedList<DiscoverCategory>();
                for (int i = 0; i < array.length(); i++) {
                    JSONObject object = array.getJSONObject(i);
                    DiscoverCategory category=new DiscoverCategory();
                    category.parseJSON(object);
                    ret.add(category);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        return ret;
    }
}
